<?php
//Lauri Link student 11 04.11.2011
 

$i = $_POST["a"];
$j = $_POST["b"];
?>
<html>
<head>
<title>Arvutamine</title>
</head>
<body bgcolor=teal text=khaki link=DarkSlateGray></body>
<p>
<form method=post action=<?php echo $PHP_SELF;?>>
<table border=1>
    <tr>
        <td>  Soovitud numbrid :</td>
     </tr>
     <tr>
        <td>A: 
            <input type=text size=35 name=a value=<?php echo $i ?>>
        </td>
    </tr>
    <tr>
        <td>B: 
            <input type=text size=35 name=b value=<?php echo $j ?>>
        </td>
    </tr>
</table>
<p>
<input type=submit name=tehe value=Liida>
<input type=submit name=tehe value=Lahuta>
<input type=submit name=tehe value=Korruta>
<input type=submit name=tehe value=Jaga>
</form>
</html>
<hr>
<?php
if ((is_numeric ($i)) && (is_numeric ($j)))
    {
    echo "<b> Ja vastus on : </b>";
    if ($_POST['tehe'] == Liida)
        {
        echo "A + B = ".($i + $j);
        }
    if ($_POST['tehe'] == Lahuta)
        {
        echo "A - B = ".($i - $j);
        }
    if ($_POST['tehe'] == "Korruta")
        {
        echo "A * B = ".($i * $j);
        }
    if ($_POST['tehe'] == "Jaga")
        {
            if($j == 0)
            {
            echo "Nulliga ei saa jagada.";
            }
            else
            {
            echo "A / B = ".($i / $j);
            }
        }
    }
else
    {
    echo "Arvutada oskan ainult numbritega.";
    }
?>